package com.happy.seatwork;

import javax.swing.JOptionPane;

public class Total_shopping_amount {
    static void discount(double sum){
        int coupon = 0;
        if (sum >= 1000){
            sum *= 0.8;
            coupon = 200;
        }
        else if (sum >= 500){
            sum *= 0.85;
            coupon = 100;
        }
        else if (sum >= 300){
            sum *= 0.9;
            coupon = 70;
        }
        else{
            sum *= 0.95;
            coupon = 0;
        }
        JOptionPane.showMessageDialog(null,"实际支付的金额为" + sum);
        JOptionPane.showMessageDialog(null,"获得的购物卷金额为" + coupon);
    }
    public static void main(String args[]){
        double shopping_sum;
        String s1;
        s1 = JOptionPane.showInputDialog(null,"请输入商品总金额");
        shopping_sum = Double.parseDouble(s1);
        discount(shopping_sum);
    }
}
